import javax.jws.Oneway;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likai
 * Date:2022-10-10
 * Time:18:21
 */
class MyArray<T>{
    T[] obj=(T[])new Object[10];

    public T getObj(int pos) {
        return obj[pos];
    }

    public void setObj(T obj,int pos) {
        this.obj[pos] = obj;
    }
}
//静态方法
class MyArray1<T>{
    T[] obj=(T[])new Object[10];
    public static<T extends Comparable<T>> T findMax(T[] array){
        T max=array[0];
        for (int i = 1; i < array.length; i++) {
           if(max.compareTo(array[i])<0){
               max=array[i];
           }
        }
        return max;
    }
}
class MyArray2<T extends Comparable<T>>{
    public  T findMax(T[] array){
        T max=array[0];
        for (int i = 1; i < array.length; i++) {
            if(max.compareTo(array[i])<0){
                max=array[i];
            }
        }
        return max;
    }
}
class Person implements Comparable<Person>{
    public int age;

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                '}';
    }

    public Person(int age){
       this.age=age;
   }

    @Override
    public int compareTo(Person o) {
        return this.age-o.age;
    }
}
class Message<T>{
    private T message;

    public T getMessage() {
        return message;
    }

    public void setMessage(T message) {
        this.message = message;
    }

}

public class Test {
    public static void fun(Message<?> message){
        message.getMessage();
    }
//    public static void fun(Message<String> message){
//        message.getMessage();
//    }


    public static void main(String[] args) {
        Message<String> message=new Message<>();
        message.setMessage("hahaha");
        fun(message);
    }




    public static void main4(String[] args) {
        Person person1=new Person(10);
        Person person2=new Person(15);
        Person []people={new Person(10),new Person(15)};
        MyArray2<Person> personMyArray2=new MyArray2<Person>();
        Person ret=personMyArray2.findMax(people);
        System.out.println(ret);
    }
    public static void main3(String[] args) {
        Integer[] array={1,2,3,4};
        MyArray2<Integer> myArray2=new MyArray2<>();
        Integer ret=myArray2.findMax(array);
        System.out.println(ret);

    }
    public static void main2(String[] args) {
        Integer[] array={1,2,3,4};
        Integer ret=MyArray1.findMax(array);
        System.out.println(ret);
    }
    public static void main1(String[] args) {
        MyArray <Integer> myArray=new MyArray();
        myArray.setObj(1,1);
        myArray.getObj(1);
    }
}
